package com.woniuxy.vuecli.entity;

import com.woniuxy.vuecli.validategroup.EmployeeAddValidate;
import com.woniuxy.vuecli.validategroup.EmployeeModifyValidate;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 * @Author author
 * @Create 2024-01-15 15:11
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class Employee {
    private Integer eid;
//    @NotNull(message = "ename--NotNull")
//    @NotEmpty(message = "ename--NotEmpty")
    @NotBlank(message = "ename-NotBlank",groups ={EmployeeAddValidate.class, EmployeeModifyValidate.class})
    @Size(min=3,max = 5,message = "ename=size-{min}-{max}",groups ={EmployeeAddValidate.class, EmployeeModifyValidate.class})
    @Length
    private String ename;
    private String password;
    private String gender;
    private String birthdate;
    @NotBlank(message = "email-NotBlank",groups ={EmployeeAddValidate.class})
//    @Email(message = "邮箱格式错误")
    @Pattern(regexp = "^\\w+@\\w+\\.\\w+$",message = "邮箱格式错误",groups ={EmployeeAddValidate.class} )
    private String email;
    //域属性：一对一
    @Valid  //级联验证
    @NotNull(message = "department-NotNull",groups ={EmployeeAddValidate.class})
    private Department department;
    //员工所有的角色
    private Integer rid;
    //删除状态，所有的删除操作都是逻辑删除(假删除，执行的是update)
    //0未删除，1已删除
    private Integer isdelete;
}
